import { request } from './request.js';

// 获取当前用户的账单列表
export function getUserBills(params = {}) {
  return request({
    url: '/api/finance/user-bills/',
    method: 'GET',
    params
  });
}

// 获取账单详情
export function getBillDetail(billId) {
  if (!billId || billId === 'null' || billId === 'undefined') {
    console.error('getBillDetail: 无效的账单ID', billId);
    return Promise.reject(new Error('无效的账单ID'));
  }
  
  return request({
    url: `/api/finance/bills/${billId}/`,
    method: 'GET'
  });
}

// 支付账单
export function payBill(billId, data) {
  if (!billId || billId === 'null' || billId === 'undefined') {
    console.error('payBill: 无效的账单ID', billId);
    return Promise.reject(new Error('无效的账单ID'));
  }
  
  console.log(`正在请求支付API: /api/finance/bills/${billId}/pay/`, data);
  
  return request({
    url: `/api/finance/bills/${billId}/pay/`,
    method: 'POST',
    data
  });
} 